package www.wf.pro.controller;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import www.wf.pro.model.ResultModel;
import www.wf.pro.request.AdminRequest;
import www.wf.pro.response.AdminResponse;

/**
 * @author wangfei
 * @date 2020-07-27 20:41
 */
@Slf4j
@RestController
@RequestMapping("adminApi/home")
@Api(description = "登录")
public class LoginController extends BaseController{

    @ApiOperation(value = "总后台登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginName", value = "登录名称", required = true, paramType = "String"),
            @ApiImplicitParam(name = "passWord", value = "登录密码", required = true, paramType = "String"),
    })
    @PostMapping("login")
    public ResultModel<AdminResponse> login(AdminRequest request) {
        log.info("总后台登陆:{}" + request);
        return adminFeign.login(request);
    }

    @ApiOperation(value = "注册以及修改管理员信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "adminId", value = "管理员id",  paramType = "Integer"),
            @ApiImplicitParam(name = "loginName", value = "登录名", required = true, paramType = "String"),
            @ApiImplicitParam(name = "passWord", value = "密码", required = true, paramType = "String"),
            @ApiImplicitParam(name = "sex", value = "性别", paramType = "Integer"),
    })
    @PostMapping("register")
    public ResultModel<Integer> register(AdminRequest request){
        log.info("进入注册以及修改管理员:{}" + JSON.toJSONString(request));
        return adminFeign.register(request);
    }



}
